package sng.utils
{
	import flash.display.Sprite;
	import flash.events.TimerEvent;
	import flash.text.TextField;
	import flash.utils.Timer;
	
	import mx.controls.TextInput;
	
	import sng.modules.model.vo.MainVO;
	
	import spark.core.SpriteVisualElement;

	/**
	 * 
	 * @author easonyang
	 */
	public class IconUtil
	{
		
		private var _value:int;
		private var _initValue:int;
		private var _property:String;
		private var _vo:MainVO;
		private var _timer:Timer;

		private static const SPEED:int=150;
		private static const TIME:int=10;

		public function IconUtil(initValue:int,value:int,vo:MainVO,property:String)
		{
			this._initValue=initValue;
			this._value=value;
			this._vo=vo;
			this._property=property;
			_timer=new Timer(SPEED,TIME);
			_timer.addEventListener(TimerEvent.TIMER,addValue);
			_timer.addEventListener(TimerEvent.TIMER_COMPLETE,addValueComplete);
			_timer.start();
		}
		
		private function addValue(evt:TimerEvent):void
		{
			if(_property=="money")
				_vo.money+=_value/TIME;
		}
		
		private function addValueComplete(evt:TimerEvent):void
		{
			_timer.removeEventListener(TimerEvent.TIMER,addValue);
			_timer.removeEventListener(TimerEvent.TIMER_COMPLETE,addValueComplete);
			_timer=null;
		}
		
		public static function changeValue(vo:MainVO,property:String,value:int):void
		{
			
			if(property=="money")
			{
				var iconUtil:IconUtil=new IconUtil(vo.money,value,vo,property);
			}
		}
	}
}